package com.yoooya.base.model.vo;

import java.util.Date;
import java.util.List;

/**
 * 分页封装类 用于做分页查询的基础类，封装了一些分页的相关属性
 * 
 * @创建人 Sun Yijing
 * @创建时间 2018-06-28
 */
public class PaginationVo<T> {

	// 下一页
	private int page;

	// 当前页
	private int currentPage;

	// 每页个个数
	private int pageSize;

	// 总条数
	private int totalCount;

	// 总页数
	private int pageCount;

	/**
	 * 刷新时间
	 */
	private Date refreshTime;

	/**
	 * 第一条头条的创建时间
	 */
	private Long firstTime;

	/**
	 * 最后一条头条的创建时间
	 */
	private Long lastTime;

	/**
	 * 刷新类型 1-上拉，2-下拉
	 */
	private Integer refreshType;

	// 记录
	private List<T> results;

	public int getPageCount() {
		return (totalCount + pageSize - 1) / pageSize;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getPage() {
		if (page <= 0) {
			return 1;
		} else {
			return page > pageCount ? pageCount : page;
		}
	}

	public void setPage(int page) {
		this.page = page;
	}

	public List<T> getResults() {
		return results;
	}

	public void setResults(List<T> results) {
		this.results = results;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize <= 0 ? 10 : pageSize;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public void resetPage() {
		page = currentPage + 1;
		pageCount = totalCount % pageSize == 0 ? totalCount / pageSize
				: totalCount / pageSize + 1;

	}

	public Date getRefreshTime() {
		return refreshTime;
	}

	public void setRefreshTime(Date refreshTime) {
		this.refreshTime = refreshTime;
	}

	public Long getFirstTime() {
		return firstTime;
	}

	public Long getLastTime() {
		return lastTime;
	}

	public void setFirstTime(Long firstTime) {
		this.firstTime = firstTime;
	}

	public void setLastTime(Long lastTime) {
		this.lastTime = lastTime;
	}

	/**
	 * 刷新类型 1-上拉，2-下拉
	 * 
	 * @return
	 */
	public Integer getRefreshType() {
		return refreshType;
	}

	/**
	 * 刷新类型 1-上拉，2-下拉
	 * 
	 * @param refreshType
	 */
	public void setRefreshType(Integer refreshType) {
		this.refreshType = refreshType;
	}
}
